package test.threads.sync;

public class Task extends Thread {

	private Worker worker;

	public Task(String name, Worker worker) {

		super(name);
		this.worker = worker;
	}

	public void run() {

		System.out.println(getName() + " started");

		try {
			Thread.sleep((long) (Math.random() * 5000));
		} catch (InterruptedException e) {
		}

		System.out.println(getName() + " finished");

		WorkerPool.freeWorker(worker);
	}
}
